package cn.goktech.sports.modules.contentManage.service.impl;

import cn.goktech.sports.common.entity.Page;
import cn.goktech.sports.common.entity.Query;
import cn.goktech.sports.common.entity.R;
import cn.goktech.sports.common.utils.CommonUtils;
import cn.goktech.sports.modules.contentManage.dao.ContentClassificationMapper;
import cn.goktech.sports.modules.contentManage.entity.ContentClassificationEntity;
import cn.goktech.sports.modules.contentManage.service.ContentClassificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 内容分类表
 * @author duanyu<>
 */
@Service("contentClassificationService")
public class ContentClassificationServiceImpl implements ContentClassificationService {

	@Autowired
    private ContentClassificationMapper contentClassificationMapper;

    /**
     * 分页查询
     * @param params
     * @return
     */
	@Override
	public Page<ContentClassificationEntity> listContentClassification(Map<String, Object> params) {
		Query query = new Query(params);
		Page<ContentClassificationEntity> page = new Page<>(query);
		contentClassificationMapper.listForPage(page, query);
		return page;
	}

    /**
     * 新增
     * @param contentClassification
     * @return
     */
	@Override
	public R saveContentClassification(ContentClassificationEntity contentClassification) {
		int count = contentClassificationMapper.save(contentClassification);
		return CommonUtils.msg(count);
	}

    /**
     * 根据id查询
     * @param id
     * @return
     */
	@Override
	public R getContentClassificationById(Long id) {
		ContentClassificationEntity contentClassification = contentClassificationMapper.getObjectById(id);
		return CommonUtils.msg(contentClassification);
	}

    /**
     * 修改
     * @param contentClassification
     * @return
     */
	@Override
	public R updateContentClassification(ContentClassificationEntity contentClassification) {
		int count = contentClassificationMapper.update(contentClassification);
		return CommonUtils.msg(count);
	}

    /**
     * 删除
     * @param id
     * @return
     */
	@Override
	public R batchRemove(Long[] id) {
		int count = contentClassificationMapper.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

	@Override
	public R list() {
		List<ContentClassificationEntity> list = contentClassificationMapper.list();
		return CommonUtils.msg(list);
	}
}
